//
//  InterView.m
//  项目三
//
//  Created by rimi on 15/10/8.
//  Copyright (c) 2015年 rimi. All rights reserved.
// 197 119 47 47 44

#import "InterView.h"

@interface InterView () {

    UIButton *_currentBtn;
}

- (void)initializeUserInterface; /**< 初始化用户界面 */

@end

@implementation InterView

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self initializeUserInterface];
    }
    return self;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        [self initializeUserInterface];
    }
    return self;
}

- (void)initializeUserInterface {
    
    self.backgroundColor = COLOR(205, 205, 205, 1);
    
    UIImageView *backgroundView = [[UIImageView alloc] initWithFrame:DHFlexibleFrame(CGRectMake(0 , 80, 708, 860))];
    backgroundView.image = [UIImage imageNamed:@"背景-附近网点"];
    [self addSubview:backgroundView];
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:DHFlexibleFrame(CGRectMake(193, 91, 336, 75))];
    imageView.image = [UIImage imageNamed:@"500-3000米未选中"];
    [self addSubview:imageView];
    
    for (int i = 0 ; i < 4; i ++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setFrame:DHFlexibleFrame(CGRectMake(197 + 96 * i, 120, 47, 44))];
        [btn setBackgroundImage:[UIImage imageNamed:@"500-1km-2km 选中"] forState:UIControlStateSelected];
        [btn addTarget:self action:@selector(respondsToInterBtn:) forControlEvents:UIControlEventTouchUpInside];
        if (i == 0) {
            _currentBtn = btn;
            _currentBtn.selected = YES;
        }
        [self addSubview:btn];
    }
    [self respondsToInterBtn:_currentBtn];
}
- (void)respondsToInterBtn:(UIButton *)sender {

    if (sender == _currentBtn) {
        return;
    }
    sender.selected = YES;
    _currentBtn.selected = NO;
    _currentBtn = sender;
}
@end
